package com.cmc.cloud.cmclink.doc.controller.admin.special;

import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.convert.SpecialCargoCntrConvert;
import com.cmc.cloud.cmclink.doc.entity.SpecialCargoCntrDO;
import com.cmc.cloud.cmclink.doc.service.SpecialCargoCntrService;
import com.cmc.cloud.cmclink.doc.vo.specialcargocntrvo.SpecialCargoCntrBaseVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargocntrvo.SpecialCargoCntrPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargocntrvo.SpecialCargoCntrRespVO;
import com.cmc.cloud.cmclink.doc.vo.specialcargocntrvo.SpecialCargoCntrUpdateReqVO;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


/**
 * 特种货审批的箱型信息前端接口Controller
 *
 * @author codegen
 */
@Tag(name = "管理后台 - 特种货审批的箱型信息")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "/specialCargoCntr")
public class SpecialCargoCntrController {

    @Resource
    private SpecialCargoCntrService specialCargoCntrService;

    @Operation(summary = "创建特种货审批的箱型信息")
    @PostMapping("/create")
    public CommonResult<Long> createSpecialCargoCntr(@Valid @RequestBody SpecialCargoCntrBaseVO createReqVO) {
        return CommonResult.success(specialCargoCntrService.createSpecialCargoCntr(createReqVO));
    }

    @Operation(summary = "更新特种货审批的箱型信息")
    @PostMapping("/update")
    public CommonResult<Void> updateSpecialCargoCntr(@Valid @RequestBody SpecialCargoCntrBaseVO updateReqVO) {
        specialCargoCntrService.updateSpecialCargoCntr(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除特种货审批的箱型信息")
    @PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Void> deleteSpecialCargoCntr(@PathVariable("id") Long id) {
        specialCargoCntrService.deleteSpecialCargoCntr(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得特种货审批的箱型信息")
    @GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<SpecialCargoCntrRespVO> getSpecialCargoCntr(@PathVariable("id") Long id) {
        SpecialCargoCntrRespVO specialCargoCntr = specialCargoCntrService.getSpecialCargoCntr(id);
        return CommonResult.success(specialCargoCntr);
    }

    @Operation(summary = "获得特种货审批的箱型信息列表")
    @GetMapping("/list")
    @Parameter(name = "applyId", description = "主信息ID", required = true)
    public CommonResult<List<SpecialCargoCntrRespVO>> getSpecialCargoCntrList(@RequestParam("applyId")Long applyId) {
        return CommonResult.success(specialCargoCntrService.getSpecialCargoCntrList(applyId));
    }

    @Operation(summary = "获得特种货审批的箱型信息分页")
    @PostMapping("/page")
    public CommonResult<PageResult<SpecialCargoCntrRespVO>> getSpecialCargoCntrPage(@Valid @RequestBody SpecialCargoCntrPageReqVO pageVO) {
        PageResult<SpecialCargoCntrRespVO> pageResult = specialCargoCntrService.getSpecialCargoCntrPage(pageVO);
        return CommonResult.success(pageResult);
    }
}
